package com.frxuexi.mdm2202.viewmodel

import androidx.lifecycle.ViewModel
import com.tencent.mmkv.MMKV
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import javax.inject.Inject

@HiltViewModel
class AppViewModel @Inject constructor():ViewModel() {

    //是否进入过的状态
    private val _isFirst =MutableStateFlow(MMKV.defaultMMKV().decodeBool("isIn",false))
    val isFirst:StateFlow<Boolean>
        get() = _isFirst

    fun emitFirst(first:Boolean){
        _isFirst.value=first
        //把进入的状态保持
        MMKV.defaultMMKV().encode("isIn",first)
    }
}